package com.csdj.web.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * packageName com.csdj.web.filter
 *
 * @author winver
 * @version 1.0
 * @className CharacterFilter
 * @date 2024/11/28
 * @description TODO
 */

@WebFilter(urlPatterns = "/*")
public class CharacterFilter implements Filter {
    @Override
    public void doFilter(ServletRequest servletRequest,
                         ServletResponse servletResponse,
                         FilterChain filterChain) throws IOException, ServletException {
        System.out.println("经过过滤器了~~~~~~~~~~~~~~~~~~~~~");
        servletRequest.setCharacterEncoding("utf-8");
        servletResponse.setCharacterEncoding("utf-8");
        filterChain.doFilter(servletRequest,servletResponse);//放行 继续下一步
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        Filter.super.init(filterConfig);
    }

    @Override
    public void destroy() {
        Filter.super.destroy();
    }
}
